#ifndef PINQLISTVIEW_H
#define PINQLISTVIEW_H

#include <QikViewBase.h>
#include "PinQTask.h"
#include "PinQModel.h"
#include "PinQAppUi.h"
#include "PinQ.hrh"


class CQikListBox;
class CQikCommandManager;
class MQikListBoxData;
class MQikListBoxModel;

class CPinQListView : public CQikViewBase,public MQikListBoxObserver
	{
public:
	static CPinQListView* NewLC(CQikAppUi& aAppUi,const TVwsViewId aParentViewId);
	~CPinQListView();
	TVwsViewId ViewId()const;
	inline TBool IsActivated() const {return CQikViewBase::IsActivated();}
	void RefreshListBoxL(); // from CategoryChanged
	void TaskStateChangedL(const CPinQTask& aTask,CPinQTask::TState aNewState); 

protected: 
	void ViewActivatedL(const TVwsViewId &aPrevViewId,
			TUid aCustomMessageId,
			const TDesC8 &CustomMessage);
	CQikCommand* DynInitOrDeleteCommandL(CQikCommand* aCommand, const CCoeControl& aControlAddingCommands);
	void ViewConstructL();
	void CPinQListView::SaveL();

private:
	inline CPinQAppUi& PinQAppUi() const {return static_cast<CPinQAppUi&>(iQikAppUi);}
	inline CPinQModel& PinQModel() const{return static_cast<CPinQAppUi&>(iQikAppUi).PinQModel();}

	void HandleCommandL(CQikCommand& aCommand);
	void HandleListBoxEventL(CQikListBox* aListBox, TQikListBoxEvent aEventCategory, TInt aItemIndex, TInt aSlotId);

	void ViewCmdL();
	void PacketsCmdL();
	void NewItemCmdL();
	void DeleteItemCmdL();
	void UndoDeleteCmdL();	
	void HandleSelectionChanged(const CQikListBox& aListBox);
	void ItemUpdatedL(TUid aUid); //after "Change View"
	void ItemDeletedL(const TUid& aUid);// const; //after Delete
	void RefreshListBoxL(const CQikListBox& aListBox);//XXX const; 
	void AddTaskL(MQikListBoxModel& aModel,CPinQTask& aTask) const; //Internal of Refres and Updated
	
	void UpdateDeleteCmdL(TBool aAvailable) const; //Update command according to current state
	void UpdateTaskCmdL();
	void UpdateTaskStateL(TInt aItemIndex);

	void SetZoomFactorL(TInt aZoomLevel);
	
	static TInt Compare(const MQikListBoxData& aFirst, const MQikListBoxData& aSecond);

	CPinQListView(CQikAppUi& aAppUi, const TVwsViewId aParentViewId);
	void ConstructL();
	void SetSlot2L(const TDesC& aText,TUid aUid);// const;
	//inline CQikListBox& ListBox() {return *(LocateControlByUniqueHandle<CQikListBox>(EPinQListViewListCtrl));}
/*	
	virtual void Started();
	virtual void Finished();
	virtual void Cancelled();
	virtual void Sent();
	*/

private:
	CQikCommandManager&	iCommandManager;
	CQUiConfigClient&	iConfigClient;
	};

#endif // PINQLISTVIEW_H
